home *** CD-ROM | disk | FTP | other *** search
/ Workplace Effectiveness: Critical Thinking Skills / Workplace Effectiveness: Critical Thinking Skills.iso / pc / Files / Rewind.dxr / 00030.txt < prev    next >
Encoding:
Text File  |  1998-09-14  |  2.4 KB  |  56 lines

  1. OOP sound sequence
  2. Here's one possible way to queue up and sequentially play a number of internal soundfiles. Although it uses parent/child scripting it's very straightforward. Paste the following handlers into a parent script window and then check that linebreaks made it across the web as expected:
  3.  
  4.  --  Parent script name: "Jukebox class"
  5.  property myChannel, myPlayList, myCurrentSound
  6.  
  7.                  on new me, whatChannel, whatSounds
  8.                    set myChannel to whatChannel
  9.                    set myPlayList to whatSounds
  10.                    set myCurrentSound to ""
  11.                    add the actorList, me
  12.                    return me
  13.                  end
  14.  
  15.                  on stepFrame me   --exitframe?
  16.                    if count(myPlayList) = 0 then exit
  17.                    if NOT soundBusy(myChannel) then
  18.                      set myCurrentSound to getAt(myPlayList, 1)
  19.                      puppetSound myChannel, myCurrentSound
  20.                      deleteAt(myPlayList, 1)
  21.                    end if
  22.                  end
  23.  
  24.                  on AddSound me, whatSound
  25.                    add myPlayList, whatSound
  26.                  end
  27.  
  28.                  on GetCurrentSound me
  29.                    if NOT soundBusy(myChannel) then set myCurrentSound to ""
  30.                    return myCurrentSound
  31.                  end
  32.  
  33. If you copy and paste the above into a parent script, then you can use something like the following in a movie script to initialize it (arbitrary sound channels and members are used here):
  34.  
  35. on startMovie
  36.    set the actorList to []
  37.    global gJukebox
  38.    set gJukeBox to new (script "Jukebox Class", 2, [member "mazurka" of castLib "audio", member "conjunto" of castLib "audio"])
  39. end
  40. -----------------------------------------------------------------
  41. When the movie starts then the sound named "mazurka" will play, then the sound named "conjunto". You can add sounds and query the current sound with things like the following, from the Message Window:
  42.  
  43.  showglobals
  44.  
  45.  -- Global Variables --
  46.  version = "6.0"
  47.  gJukebox = <offspring "Jukebox class" 2 10d1e68>
  48.  
  49.  put GetCurrentSound(gJukebox)
  50. -- (member "mazurka" of castLib "audio")
  51. AddSound(gJukebox, member "slow tango" of castLib "audio")
  52.  
  53. As with all Lingo technotes, this will not be appropriate for every project, but it does show a path that can be used in some projects. The scripting can also be used as a springboard for your own work... it is just a suggestion.
  54.  
  55. Author:  John Dowdell
  56.